/*
import java.util.Arrays;

//比较数组中存储的字符串是否完全一致
public class Test {
    public static void main(String[] args) {
        int[] array = { 1, 2, 3, 4, 5};
        int[] array2 = { 1, 3, 4, 5, 6};
        int[] array3 = {3, 5, 4, 3 ,2};
        int[] array4 = { 1, 2, 3, 4, 5};
        System.out.println(Arrays.equals(array, array2));
        System.out.println(Arrays.equals(array, array3));
        System.out.println(Arrays.equals(array, array4));
    }
}
*/







/*//填充数组

import java.util.Arrays;

public class Test {
    public static void main(String[] args) {
        int[] array = new int[10];
        Arrays.fill(array, -1);
        System.out.println(Arrays.toString(array));// -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
    }
}*/








//填充数组

/*
import java.util.Arrays;

public class Test {
    public static void main(String[] args) {
        int[] array = new int[10];
        Arrays.fill(array, 1 , 4 ,-1);
        System.out.println(Arrays.toString(array));
    }
}*/








/*//冒泡排序

import java.util.Arrays;

public class Test {
    public static void bubbleSort(int[] array){
        for (int i = 0; i < array.length - 1; i++) {
            boolean flag = false;
            for (int j = 0; j < array.length - 1 - i; j++) {
                if(array[j] > array[j + 1]){
                    int tmp = array[j];
                    array[j] = array[j + 1];
                    array[j + 1] = tmp;
                    flag = true;
                }
            }
            if(flag == true){
                break;
            }
        }
    }
    public static void main(String[] args) {
        int[] array = {1 , 42, 23, 14 , 55};
        bubbleSort(array);
        System.out.println(Arrays.toString(array));
    }
}*/







/*
//将数组中的每个数字扩大2倍并打印

import java.util.Arrays;

public class Test {
    public static void transform(int[] array){
        for (int i = 0; i < array.length; i++) {
            array[i] = array[i] * 2 ;
        }
    }
    public static void main(String[] args) {
        int[] array = { 1, 2, 3, 4, 5};
        System.out.println(Arrays.toString(array));
        transform(array);
        System.out.println(Arrays.toString(array));
    }
}
*/







/*//将数组中的每个数字扩大2倍并打印

import java.util.Arrays;

public class Test {
    public static int[] transform(int[] array){
        int[] ret = new int[array.length];
        for (int i = 0; i < array.length; i++) {
            ret[i] = array[i] * 2 ;
        }
        return ret;
    }
    public static void main(String[] args) {
        int[] array = { 1, 2, 3, 4, 5};
        System.out.println(Arrays.toString(array));
        int[] ret = transform(array);
        System.out.println(Arrays.toString(ret));
    }
}*/








//查找数字中是否存在两个下标相加等于所给的数组，下标不可重复
/*
import java.util.Arrays;
import java.util.Scanner;

public class Test {

    public static int[] func(int[] array , int k){
        for (int i = 0; i < array.length - 1 ; i++) {
            for (int j = i + 1; j < array.length; j++) {
                if(array[i] + array[j] == k){
                    return new int[] {i , j};
                }
            }
        }
        return new int[]{ -1 , -1};
    }
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int[] array = {2, 7 , 11 , 15 };
        int k = scan.nextInt();
        int[] ret = func(array , k);
        System.out.println(Arrays.toString(ret));
    }
}*/







/*
//求数组中只出现了1次的数字

public class Test {
    public static int findNum(int[] array){
        int ret = array[0];
        for (int i = 1; i < array.length; i++) {
            ret ^= array[i];
        }
        return ret;
    }

    public static void main(String[] args) {
        int[] array = { 1, 3, 2, 2, 1};
        System.out.println(findNum(array));
    }
}*/







/*
//将数组中的所有奇数置于偶数之前

import java.util.Arrays;

public class Test {
    public static void func(int[] array){
        int left = 0;
        int right = array.length - 1;
        while(left < right){
             while (left < right && array[left] % 2 == 1) {
                    left++;
                   }
            while(left < right && array[right] % 2 == 0){
                    right--;
                 }
                int tmp = array[left];
                array[left] = array[right];
                array[right] = tmp;
            }
        }

    public static void main(String[] args) {
        int[] array = { 1, 2, 3, 5, 7, 4 };
        func(array);
        System.out.println(Arrays.toString(array));
    }
}*/







/*
//请判断数组中是否存在三个连续的奇数

public class Test {
    public static boolean func(int[] array){
        int count = 0;
        for (int i = 0; i < array.length; i++) {
            if(array[i] % 2 != 0){
                count++;
                if(count == 3){
                    return true;
                }
            } else {
                    count = 0;
                }
            }
        return false;
    }
    public static void main(String[] args) {
        int[] array = { 1, 2, 1, 3, 1, 2, 1, 1, 3};
        System.out.println(func(array));
    }
}*/







/*
//数组逆序

import java.util.Arrays;

public class Test {
    public static void reverstring(int[] array){
        int left = 0;
        int right = array.length - 1;
        while (left < right) {
            int tmp = array[left];
            array[left] = array[right];
            array[right] = tmp;
            left++;
            right--;
        }
    }

    public static void main(String[] args) {
        int[] array = { 1, 12, 43, 24, 5, 76, 21 };
        reverstring(array);
        System.out.println(Arrays.toString(array));
    }
}*/
